<template>
  <div class="home">
    <img alt="Vue logo" src="../assets/logo.png" />
    <HelloWorld :msg="hello" />
  </div>
</template>

<script>
// @ is an alias to /src
import HelloWorld from "@/components/HelloWorld.vue";
import { getMsg } from "@/api/app";

export default {
  name: "Home",
  components: {
    HelloWorld,
  },
  data() {
    return {
      hello: "HELLP NIL APP",
    };
  },
  methods: {
    initData() {
      if (!localStorage.getItem("name")) {
        getMsg().then((res) => {
          this.hello = res.data.rider_rname;
          localStorage.setItem("name", res.data.rider_rname);
        });
      } else {
        this.hello = localStorage.getItem("name");
      }
    },
  },
  created() {
    this.initData();
  },
};
</script>

<style lang="scss" scoped>
.home {
  height: 90vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
</style>